﻿'Public MustInherit Class TokenTerminal(Of TToken)
'    Inherits Terminal

'    Public MustOverride Function Match(ByVal token As TToken) As Boolean
'End Class


'Public Class SingleTokenTerminal(Of TToken)
'    Inherits TokenTerminal(Of TToken)
'    Private m_tokenComparer As IEqualityComparer(Of TToken)
'    Protected ReadOnly Property TokenComparer() As IEqualityComparer(Of TToken)
'        Get
'            Return m_tokenComparer
'        End Get
'    End Property

'    Private ReadOnly m_matchToken As TToken
'    Public ReadOnly Property MatchToken() As TToken
'        Get
'            Return m_matchToken
'        End Get
'    End Property

'    Public Sub New(ByVal matchToken As TToken)
'        MyClass.New(matchToken, EqualityComparer(Of TToken).Default)
'    End Sub

'    Public Sub New(ByVal matchToken As TToken, ByVal tokenComparer As IEqualityComparer(Of TToken))
'        Contract.ArgumentNotNull(tokenComparer, "tokenComparer")

'        m_tokenComparer = tokenComparer
'        m_matchToken = matchToken
'    End Sub

'    Public Overrides Function Match(ByVal token As TToken) As Boolean
'        Return TokenComparer.Equals(m_matchToken, token)
'    End Function
'End Class

'Public Class PredicateTerminal(Of TToken)
'    Inherits TokenTerminal(Of TToken)

'    Private m_predicate As Func(Of TToken, Boolean)

'    Public Sub New(ByVal predicate As Func(Of TToken, Boolean))
'        Contract.ArgumentNotNull(predicate, "predicate")
'        m_predicate = predicate
'    End Sub

'    Public Sub New(ByVal predicate As Predicate(Of TToken))
'        MyClass.New(New Func(Of TToken, Boolean)(AddressOf predicate.Invoke))
'    End Sub

'    Public Shared Widening Operator CType(ByVal predicate As Func(Of TToken, Boolean)) As PredicateTerminal(Of TToken)
'        Return New PredicateTerminal(Of TToken)(predicate)
'    End Operator

'    Public Overrides Function Match(ByVal token As TToken) As Boolean
'        Return m_predicate(token)
'    End Function
'End Class

'Public Class ExceptTokenTerminal(Of TToken)
'    Inherits TokenTerminal(Of TToken)
'    Private m_tokenComparer As IEqualityComparer(Of TToken)
'    Protected ReadOnly Property TokenComparer() As IEqualityComparer(Of TToken)
'        Get
'            Return m_tokenComparer
'        End Get
'    End Property

'    Private ReadOnly m_exceptToken As TToken
'    Public ReadOnly Property MatchToken() As TToken
'        Get
'            Return m_exceptToken
'        End Get
'    End Property

'    Public Sub New(ByVal exceptToken As TToken)
'        MyClass.New(exceptToken, EqualityComparer(Of TToken).Default)
'    End Sub

'    Public Sub New(ByVal exceptToken As TToken, ByVal tokenComparer As IEqualityComparer(Of TToken))
'        Contract.ArgumentNotNull(tokenComparer, "tokenComparer")

'        m_tokenComparer = tokenComparer
'        m_exceptToken = exceptToken
'    End Sub

'    Public Overrides Function Match(ByVal token As TToken) As Boolean
'        Return Not TokenComparer.Equals(m_exceptToken, token)
'    End Function
'End Class

'Public Class RangeTokenTerminal(Of TToken)
'    Inherits TokenTerminal(Of TToken)

'    Private m_tokenComparer As IComparer(Of TToken)
'    Protected ReadOnly Property TokenComparer() As IComparer(Of TToken)
'        Get
'            Return m_tokenComparer
'        End Get
'    End Property

'    Private ReadOnly m_upperToken As TToken
'    Private ReadOnly m_lowerToken As TToken

'    Public ReadOnly Property UpperToken() As TToken
'        Get
'            Return m_upperToken
'        End Get
'    End Property

'    Public ReadOnly Property LowerToken() As TToken
'        Get
'            Return m_lowerToken
'        End Get
'    End Property

'    Public Sub New(ByVal lowerToken As TToken, ByVal upperToken As TToken)
'        MyClass.New(lowerToken, upperToken, Comparer(Of TToken).Default)
'    End Sub

'    Public Sub New(ByVal lowerToken As TToken, ByVal upperToken As TToken, ByVal tokenComparer As IComparer(Of TToken))
'        Contract.ArgumentNotNull(tokenComparer, "tokenComparer")

'        If tokenComparer.Compare(lowerToken, upperToken) > 0 Then
'            Throw New ArgumentException("The lowerToken must be less than or equal to the upperToken")
'        End If

'        m_tokenComparer = tokenComparer
'        m_lowerToken = lowerToken
'        m_upperToken = upperToken
'    End Sub

'    Public Overrides Function Match(ByVal token As TToken) As Boolean
'        Return TokenComparer.Compare(token, LowerToken) >= 0 AndAlso _
'                TokenComparer.Compare(token, UpperToken) <= 0
'    End Function
'End Class